package net.zdsoft.wpchat.support.entity;

import net.zdsoft.wpchat.support.enums.PermissionTypeEnum;

/**
 * 用户操作
 *
 * @author xuan
 */
public class UserOperation {
    public static final PermissionTypeEnum PERMISSION_ALL = PermissionTypeEnum.ALL;
    public static final PermissionTypeEnum PERMISSION_SCHOOL = PermissionTypeEnum.SCHOOL;
    public static final PermissionTypeEnum PERMISSION_AREA = PermissionTypeEnum.AREA;

    private AuthOperation operation = null;
    private UserModule userModule = null;
    private PermissionTypeEnum permission = null;

    public UserOperation(AuthOperation operation, PermissionTypeEnum permission) {
        this.operation = operation;
        this.permission = permission;
    }

    public void setUserModule(UserModule userModule) {
        this.userModule = userModule;
    }

    public UserModule getUserModule() {
        return userModule;
    }

    public AuthOperation getOperation() {
        return operation;
    }

    public PermissionTypeEnum getPermission() {
        return permission;
    }

    public String getDefaultAction() {
        return operation.getAction()[0];
    }

    public boolean isPermissionAll() {
        return PERMISSION_ALL.equals(permission);
    }

    public boolean isPermissionAuth() {
        return PERMISSION_SCHOOL.equals(permission);
    }

    public boolean isPermissionArea() {
        return PERMISSION_AREA.equals(permission);
    }

}
